#include "SimulationTime.h"

#include "Config/Config.h"

#include <iomanip>
#include <string>
#include <mpi.h>
#include "Log/Log.h"

using namespace std;

SimulationTime::SimulationTime(Config* config_)
{
    itime = 0;
    timeNow = 0.0;

    dt                  = config_->sim_time_param.dt;
    timestep_simulation = config_->sim_time_param.timestep_simulation;
    timestep_io         = config_->sim_time_param.timestep_io;
    timestep_average    = config_->sim_time_param.timestep_average;
    timestep_collision  = config_->sim_time_param.timestep_collision;
    timestep_coulomb    = config_->sim_time_param.timestep_coulomb;
    timestep_DSMC       = config_->sim_time_param.timestep_DSMC;
    timestep_restore    = config_->sim_time_param.timestep_restore;

    config_->sim_time = this;
};

SimulationTime::~SimulationTime()
{
}

string SimulationTime::get_time_string_io()
{
    string step_output_string;

    int step_output = itime / timestep_io;
    int step_output_max = timestep_simulation / timestep_io;

    step_output_string = to_string(step_output);


    /*
    if(step_output_max >= 10 && step_output_max <100)
    {
        if(step_output < 10)
        {
            step_output_string = "0" + step_output_string;
        }
    }
    else if(step_output_max >= 100 && step_output_max <1000)
    {
        if(step_output < 10)
        {
            step_output_string = "00" + step_output_string;
        }
        else if(step_output<100)
        {
            step_output_string = "0" + step_output_string;
        }
    }
    else if(step_output_max >= 1000)
    {
        log_warning<<"step_output_max is too large, please change the code in IO1D.cpp";
    }
    */

    return step_output_string;
}